# 1. 列表推导式（快速生成列表）
numbers = [x * 2 for x in range(10)]
print(numbers)  # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]

# 2. 字典推导式
squares = {x: x ** 2 for x in range(5)}
print(squares)  # {0: 0, 1: 1, 2: 4, 3: 9, 4: 16}

# 3. 生成器（节省内存）
even_numbers = (x for x in range(10) if x % 2 == 0)
for num in even_numbers:
    print(num, end=" ")  # 0 2 4 6 8